package com.qunar.qcf.core.write;

import java.net.SocketAddress;

import com.qunar.qcf.core.filterchain.IoFilter;
import com.qunar.qcf.core.future.WriteFuture;
import com.qunar.qcf.core.session.IoSession;

/**
 * Represents write request fired by {@link IoSession#write(Object)}.
 *
 */
public interface WriteRequest {
    /**
     * Returns the {@link WriteRequest} which was requested originally,
     * which is not transformed by any {@link IoFilter}.
     */
    WriteRequest getOriginalRequest();

    /**
     * Returns {@link WriteFuture} that is associated with this write request.
     */
    WriteFuture getFuture();
    
    /**
     * Returns a message object to be written.
     */
    Object getMessage();

    /**
     * Returns the destination of this write request.
     *
     * @return <tt>null</tt> for the default destination
     */
    SocketAddress getDestination();
    
    /**
     * Tells if the current message has been encoded
     *
     * @return true if the message has already been encoded
     */
    boolean isEncoded();
}